package com.example.test.interfaces.facade;

import com.example.test.applicaiton.services.ArticleCategoryService;
import com.example.test.domain.entity.ArticleCategory;
import com.example.test.infrastructre.utils.OutData;
import com.example.test.applicaiton.vo.ArticleCategoryVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class ArticleCategoryFacade {
    @Resource
    ArticleCategoryService articleCategoryService;

    /**
     * 获取列表
     * @return
     */
    @GetMapping("/findAll")
    public OutData<List<ArticleCategory>> getArtCategory() {
        List<ArticleCategory> articleList = articleCategoryService.findAll();
        return new OutData<>(articleList);
    }

    @GetMapping("findOne")
    public OutData<ArticleCategoryVO> getOneCategory(@RequestParam Integer categoryId){
        ArticleCategoryVO categoryVO = articleCategoryService.findOne(categoryId);
        return new OutData<>(categoryVO);
    }
}